package com.camelot.ccr.global.util.comparator.example;

import java.util.ArrayList;
import java.util.Collections;

import com.camelot.ccr.global.util.comparator.CommonComparator;
import com.camelot.ccr.global.util.comparator.EnumComparatorType;

/**
 * 具体得排序实例，运行此类的main函数
 * @author chendd
 */
@SuppressWarnings("rawtypes")
public class TestUserComparator{

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		
		java.util.List<ComparatorExample> userList = new ArrayList<ComparatorExample>();
		userList.add(new ComparatorExample(101,"a"));
		userList.add(new ComparatorExample(103,"c"));
		userList.add(new ComparatorExample(103,""));
		userList.add(new ComparatorExample(103,"    "));
		userList.add(new ComparatorExample(103,"123"));
		userList.add(new ComparatorExample(103,null));
		userList.add(new ComparatorExample(102,null));
		userList.add(new ComparatorExample(103,"a"));
		userList.add(new ComparatorExample(103,"美a文"));
		userList.add(new ComparatorExample(103,"中a文"));
		userList.add(new ComparatorExample(103,"英a文"));
		userList.add(new ComparatorExample(102,"b"));
		userList.add(new ComparatorExample(104,"d"));
		
		CommonComparator userSort = new CommonComparator();
		userSort.setSort(EnumComparatorType.DESC.getKey());//设置排序方式
		userSort.setSortAttrs(new String[]{"id","name"});//设置相关需要排序的属性
		Collections.sort(userList, userSort);
		//排序后的结果
		for (ComparatorExample comparatorExample : userList) {
			System.out.println(comparatorExample);
		}
	}
	
}
